<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="./css/font.css">
<link rel="stylesheet" href="./css/xadmin.css">
<script type="text/javascript" src="./lib/layui/layui.js"
	charset="utf-8"></script>
<script type="text/javascript" src="./js/xadmin.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-form-item">
			<label for="L_username" class="layui-form-label">推送会馆</label>
			<div class="layui-input-inline">
				<select name="yid" id="tyid">
					<option>-请选择-</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_username" class="layui-form-label">推送教练</label>
			<div class="layui-input-inline">
				<select name="cid" id="tcid">
					<option>-请选择-</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_username" class="layui-form-label">推送内容</label>
			<div class="layui-input-inline">
				<input type="text" style="width: 400px; height: 50px" id="mes"
					name="describe" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label for="L_username" class="layui-form-label">推送地址</label>
			<div class="layui-input-inline">
				<input type="text" style="width: 400px; height: 50px" id="addr"
					name="describe" autocomplete="off" class="layui-input">
			</div>
		</div>
		<!--layui-btn设置按钮 -->
		<div class="layui-form-item">
			<label for="L_repass" class="layui-form-label"></label>
			<button onclick="post()" class="layui-btn">增加</button>
		</div>
	</div>

	<script>
		$(document).ready(function() {
			showcid();
			showyid();
		});

		function post() {
			var des = $("#addr").val() + "," + $("#mes").val();
			$.ajax({
				url : "/admin/addindexmes",
				type : "post",
				data : {
					yid : $("#tyid").val(),
					cid : $("#tcid").val(),
					describe : des
				},
				success : function(data) {
					alert(data);
					window.parent.location.reload();
					parent.layer.closeAll();
				}
			});
		}

		function showcid() {
			$.ajax({
				url : "/coach/all",
				type : "post",
				success : function(data) {
					var content = "";
					content += '<option >-请选择-</option>';
					for (var i = 0; i < data.length; i++) {
						var po = data[i]
						content += '<option value='+po.cid+'>' + po.cname
								+ '</option>';
					}
					$("#tcid").html(content);
				}
			});
		}

		function showyid() {
			$.ajax({
				url : "/yogaclub/all",
				type : "post",
				success : function(data) {
					var content = "";
					content += '<option >-请选择-</option>';
					for (var i = 0; i < data.length; i++) {
						var po = data[i]
						content += '<option value='+po.yid+'>' + po.yname
								+ '</option>';
					}
					$("#tyid").html(content);
				}
			});
		}
	</script>
</body>
</html>
